package com.itheima.dao;

import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

@Mapper
public interface OrderMapper {
    /**
     * 根据id查询预约信息
     * @param id
     * @return
     */
    @Select("select * from itcast_health.t_order where id = #{id}")
    Order findById(Integer id);


    @Select("select * from itcast_health.t_order where member_id = (select t_member.id from itcast_health.t_member where idCard = #{idCard}) and orderDate = #{orderDate}")
    Order getByIdCardAndOrderDate(String idCard, Date orderDate);

    /**
     * 添加预约信息
     * @param order
     */
    @Insert("insert into itcast_health.t_order (member_id, orderDate, orderType, orderStatus, setmeal_id) value " +
            "(#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    void add(Order order);
}
